package com.work.account2.service;

import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.BusinessActionContextParameter;
import io.seata.rm.tcc.api.LocalTCC;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;

import java.math.BigDecimal;

/**
 * @author YonJar
 * @date 2024/6/12.
 * @description
 */
@LocalTCC
public interface TccAccountService {

    /**
     * name 全局唯一; commit 就是 confirm; rollback 就是 cancel
     * @param userId
     * @param orderMoney
     */
    @TwoPhaseBusinessAction(name = "AccountTcc", commitMethod = "commit", rollbackMethod = "rollback")
    boolean prepare(BusinessActionContext context,
                    @BusinessActionContextParameter(paramName = "userId") String userId,
                    @BusinessActionContextParameter(paramName = "orderMoney") BigDecimal orderMoney);



    boolean commit(BusinessActionContext context);


    boolean rollback(BusinessActionContext context);
}
